/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package exif_to_kml;

import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 *
 * @author offsprey14@gmail.com
 */

public class ImagePanel extends JPanel implements Runnable{

    private File tfile=null;
    private BufferedImage im=null;
    public void showImage(File nfile)
    {
        tfile = nfile;
        Thread nthread = new Thread(this,"ImageThread");
        nthread.start();
        
    }
    public void showImage(BufferedImage image)
    {
        this.getGraphics().drawImage(im.getScaledInstance(this.getWidth(), this.getHeight(), Image.SCALE_SMOOTH), 0, 0,null);
    }
    public BufferedImage getBufferedImage()
    {
        return im;
    }
    public void run() {

       

        try {
            im = ImageIO.read(tfile);
            this.getGraphics().drawImage(im.getScaledInstance(this.getWidth(), this.getHeight(), Image.SCALE_SMOOTH), 0, 0,null);

        } catch (IOException ex) {

        }
    }

}
